//
//  introViewController.m
//  com.vida.demo
//
//  Created by Benjamin Hugo on 2013/11/05.
//  Copyright (c) 2013 iota. All rights reserved.
//

#import "introViewController.h"

@implementation introViewController
- (void) viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataUpdated:) name:CS_ON_SCAN object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataUpdated:) name:CS_ON_SCAN_COMPLETE object:nil];
    [BackgroundScanner startScanning];
}
- (void) viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    [BackgroundScanner stopScanning];
}
- (void)dataUpdated:(NSNotification *)notification
{
    if ([[notification name] isEqualToString:CS_ON_SCAN]){
        dispatch_async(dispatch_get_main_queue(), ^{
            [[self lblScanning] setText:@"Scanning..."];
        });
    } else if ([[notification name] isEqualToString:CS_ON_SCAN_COMPLETE]){
        dispatch_async(dispatch_get_main_queue(), ^{
            [[self lblScanning] setText:@"Idle..."];
        });
    }
}
@end
